<html>
    <head>
        <title>Build a JavaScript Calculator</title>
        <script src="../lib/jquery-1.11.2.min.js" type="text/javascript"></script>
        <style type="text/css">
            #calculator{
                text-align: center;
                width: 220px
            }
            textarea{
                width: 210px
            }
            button{
                width: 50px;
            }
        </style>
    </head>
    <body>
        <div id="calculator">
            <textarea disabled="disabled" readonly="readonly"></textarea>
            <div class="buttons">
                <button value="1">1</button>
                <button value="2">2</button>
                <button value="3">3</button>
                <button value="+">+</button>
                <button value="4">4</button>
                <button value="5">5</button>
                <button value="6">6</button>
                <button value="-">-</button>
                <button value="7">7</button>
                <button value="8">8</button>
                <button value="9">9</button>
                <button value="*">*</button>
                <button value="clear">clear</button>
                <button value="0">0</button>
                <button value="=">=</button>
                <button value="/">/</button>
            </div>
            <div id="history">

            </div>
        </div>
        <script type="text/javascript">
            var num1,num2;
            $("button").bind("click", function() {
                if (this.value==="=") {
                    $("textarea")[0].value += "=" + eval($("textarea")[0].value);
                    $("#history").append("<p>"+$("textarea")[0].value+"</p>");
                    $("textarea")[0].value = "";
                } else if (this.value==="clear") {
                    $("textarea")[0].value = "";
                } else {
                    $("textarea")[0].value = $("textarea")[0].value+this.value;
                }
            })
        </script>
    </body>
</html>